package pers.mihao.quickstream.publish.lister;

import org.springframework.stereotype.Component;
import pers.mihao.quickstream.common.task.service.AutomaticTaskInvoker;
import pers.mihao.quickstream.publish.manager.PublishDetailTaskManager;
import pers.mihao.quickstream.publish.manager.PublishTaskManager;

import javax.annotation.Resource;

import static pers.mihao.quickstream.publish.constants.TaskConstants.DETAIL_TASK;
import static pers.mihao.quickstream.publish.constants.TaskConstants.MAIN_TASK;

/**
 * @author mihao
 * @since 2024/11/23
 */
@Component
public class PublishMaterialTaskInvoker implements AutomaticTaskInvoker<PublishJobParams> {

    @Resource
    PublishTaskManager publishTaskManager;

    @Resource
    PublishDetailTaskManager publishDetailTaskManager;

    @Override
    public boolean doAutomaticTask(PublishJobParams jobParams) {
        Integer taskType = jobParams.getTaskType();
        switch (taskType) {
            case MAIN_TASK:
                publishTaskManager.parseDetailTask(jobParams.getTaskId());
                break;
            case DETAIL_TASK:
                publishDetailTaskManager.publishDetailTask(jobParams.getTaskId());
                break;
            default:
                break;
        }
        return false;
    }
}
